<?php

class epaywxjsPayment extends BasePayment {


    function get_payform($order_info) {
        $order_info=$this->get_order_info($order_info);
        
        if(!$order_info){
            return false;
        }

        define("APPID", Conf::get('payment_wx_appid'));
        define("MCHID", Conf::get('payment_wx_mch_id'));
        define("KEY", Conf::get('payment_wx_key'));
        define("APPSECRET", Conf::get('payment_wx_secret'));
        require_once (ROOT_PATH."/includes/payments/epaywxjs/WxPay.JsApiPay.php");
        $tools = new JsApiPay();
        $openId = $tools->GetOpenid(); //①、获取用户openid
        $input = new WxPayUnifiedOrder(); //②、统一下单
        $input->SetBody("微信直接支付"); //商品描述
        $input->SetAttach($order_info['order_sn']); //附加数据
        $input->SetOut_trade_no($order_info['order_sn']); //商户订单号
        $input->SetTotal_fee(intval(bcmul($order_info['money'],100 ,0))); //总金额
        $input->SetTime_start(date("YmdHis", gmtime())); //交易起始时间
        $input->SetTime_expire(date("YmdHis", gmtime() + 3600 * 24)); //交易结束时间
        $input->SetGoods_tag("微信直接支付"); //商品标记
        $input->SetNotify_url(site_url(). "/notifywx.php");
        
        
        $input->SetTrade_type("JSAPI");
        $input->SetOpenid($openId);
        $order = WxPayApi::unifiedOrder($input);
        $jsApiParameters = $tools->GetJsApiParameters($order);
        return $jsApiParameters;
    }

}
?>
